package com.it.tydic.estate.module.controller.wxgl;

import com.github.pagehelper.PageInfo;
import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;
import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.model.inner.TbWxglDjb;
import com.it.tydic.estate.module.service.WxglDjbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 维修管理 登记表
 * Created by jinghongtao on 2020/3/3.
 */

@RestController
@RequestMapping("/wxgl")
@Api(tags ="维修管理———主要：报单、派工、完工、回访")
public class WxglDjbController {

    @Resource
    WxglDjbService wxglDjbService;

    /**
     * 根据条件 分页查询
     * @param record
     * @return
     */
    @ApiOperation("根据条件 分页查询 维修管理信息")
    @PostMapping("/getDataByPageList")
    public Result getDataByPageList(@RequestBody Map<String,Object> record){
        return  wxglDjbService.queryByPage(record);
    }
    /**
     * 带条件查询维修数量统计
     * @param record
     * @return
     */
    @ApiOperation("带条件查询维修数量统计")
    @PostMapping("/selectCountWx")
    public Result selectCountWx(@RequestBody Map<String,Object> record){
        return  wxglDjbService.selectCountWx(record);
    }
    /**
     *  Excel导出
     * @param
     * @return
     */
    @ApiOperation("回访 Excel导出")
    @GetMapping("/excelExport")
    public void excelExport(HttpServletResponse response, TbWxglDjb record) throws Exception {
        wxglDjbService.excelExport(record,response) ;
    }
    /**
     *  Excel导出
     * @param
     * @return
     */
    @ApiOperation("统计数量 Excel导出")
    @GetMapping("/numExport")
    public void numExport(HttpServletResponse response,Map<String,Object> record) throws Exception {
        wxglDjbService.numExport(record,response) ;
    }
    /**
     *  根据id查询 单条
     * @param id
     * @return
     */
    @ApiOperation("根据id查询 单条")
    @GetMapping("/getDataById/{id}")
    public Result getDataById(@PathVariable("id") String id){
        return  wxglDjbService.selectByPrimaryKey(id);
    }

    /**
     * 根据id 删除单条
     * @return
     */
    @ApiOperation("根据id删除单条")
    @ControllerDesc(description = LogConstants.delete_data)
    @DeleteMapping("/deleteData/{id}")
    public Result deleteById(@PathVariable("id") String id){
        return wxglDjbService.deleteById(id);
    }
    /**
     * 根据id 删除单条
     * @return
     */
    @ApiOperation("根据id逻辑删除单条")
    @ControllerDesc(description = LogConstants.delete_data)
    @DeleteMapping("/deleteUp/{id}")
    public Result deleteUp(@PathVariable("id") String id){
        return wxglDjbService.deleteUp(id);
    }
    /**
     * 根据id 作废单条
     * @return
     */
    @ApiOperation("根据id作废单条")
    @DeleteMapping("/cancellationData/{id}")
    public Result cancellationData(@PathVariable("id") String id){
        return wxglDjbService.cancellationData(id);
    }
    /**
     * 根据id 恢复单条
     * @return
     */
    @ApiOperation("根据id 恢复单条")
    @PutMapping("/recoverData/{id}")
    public Result recoverData(@PathVariable("id") String id){
        return wxglDjbService.recoverData(id);
    }
    /**
     * 根据ids 批量删除
     * @param ids 主键ids数组
     * @return
     */
    @ApiOperation("批量逻辑删除")
    @ControllerDesc(description = LogConstants.delete_data)
    @PostMapping("/deleteByIds")
    public Result deleteByIds(@RequestBody String[] ids) {
        return wxglDjbService.deleteByIds(ids);
    }

    /**
     * 根据id更新
     * @return
     */
    @ApiOperation("根据id更新 维修管理信息")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @PutMapping("/updateData")
    public Result updateData(@RequestBody TbWxglDjb record){
        return wxglDjbService.updateData(record);
    }
    /**
     * 保存
     * @return
     */
    @ApiOperation("新增保存 维修管理信息")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @PostMapping("/saveData")
    public Result saveDate(@RequestBody TbWxglDjb record){
        return wxglDjbService.saveDate(record);
    }
}
